#!/bin/bash
clear
RED="\033[31m"    # Error message
GREEN="\033[32m"  # Success message
YELLOW="\033[33m" # Warning message
BLUE="\033[36m"   # Info message
RESET='\033[0m'

if [ "$EUID" -ne 0 ]; then
  echo -e "${RED} Anda tiada kebenaran untuk menjalankan skrip ini! ${RESET}"
  exit 1
fi

wget -q https://github.com/lfasmpao/open-http-puncher/releases/download/0.1/ohpserver-linux32.zip
unzip ohpserver-linux32.zip && rm ohpserver-linux32.zip
chmod +x ohpserver
mv ohpserver /usr/bin/

echo "[Unit]
Description=Dropbear OHP
Wants=network.target
After=network.target

[Service]
ExecStart=/usr/bin/ohpserver -port 355 -proxy 127.0.0.1:8888 -tunnel 127.0.0.1:440
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target" >/etc/systemd/system/ohp-dropbear.service
systemctl daemon-reload
systemctl enable ohp-dropbear
systemctl start ohp-dropbear

echo "[Unit]
Description=OpenVPN OHP
Wants=network.target
After=network.target

[Service]
ExecStart=/usr/bin/ohpserver -port 356 -proxy 127.0.0.1:8888 -tunnel 127.0.0.1:1194
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target" >/etc/systemd/system/ohp-openvpn.service

systemctl daemon-reload
systemctl enable ohp-openvpn
systemctl start ohp-openvpn

echo
echo -e "${GREEN} Pemasangan ohpserver pakej telah selesai. ${RESET}"
echo
